package com.muatocroi.tornado;

import android.content.Context;
import android.content.res.AssetManager;

import com.nanoHTTPD.NanoHTTPD;

public class WebServer {

	static NanoHTTPD httpServer = null;
	private static Context myContext;

	public final static int port = 2626;

	public static boolean isRunning() {
		return httpServer != null;
	}

	public static boolean start(Context context) {
		myContext = context;
		try {
			AssetManager assetManager = myContext.getAssets();
			httpServer = new NanoHTTPD(port, assetManager, "web");
			return true;
		} catch (Exception e) {
			httpServer = null;
			return false;
		}
	}

	public static void stop() {
		httpServer.stop();
		httpServer = null;
	}

}